#ifndef     __SENSOR_H
#define     __SENSOR_H

#include "../../utils/object.h"
#include "../../utils/nocopyable.h"
#include "../../rtos/mutex.h"
#include "../../utils/base.h"

namespace driver {

class Sensor : private utils::NoCopyable {

public:
    uint16_t status();

    inline bool is_elock_close() {
        return utils::is_clr_bit<2>(read());
    }

    inline bool is_pick1_guard() {
        return utils::is_clr_bit<0>(read());
    }

    inline bool is_pick2_guard() {
        return utils::is_clr_bit<1>(read());
    }

    inline bool is_pick1_open() {
        return utils::is_set_bit<8>(read());
    }

    inline bool is_pick1_close() {
        return utils::is_set_bit<9>(read());
    }

    inline bool is_pick2_open() {
        return utils::is_set_bit<10>(read());
    }

    inline bool is_pick2_close() {
        return utils::is_set_bit<11>(read());
    }

    inline bool is_pick1_check() {
        return utils::is_clr_bit<12>(read());
    }

    inline bool is_pick2_check() {
        return utils::is_clr_bit<13>(read());
    }

    Sensor();

private:
    uint16_t read();

    rtos::Mutex m_mutex;
};

inline utils::Object<Sensor> sensor;

}

#endif
